#include "StdAfx.h"
#include "GraphKLine.h"

CGraphKLine::CGraphKLine(void)
{
}

CGraphKLine::~CGraphKLine(void)
{
}


AGraphDateBase* CGraphKLine::GetGrapData( std::string strStockCode )
{
	AGraphKLine *pKline = new AGraphKLine();

	AddPoint(pKline, _T("2010-01-26"), _T("2010-01-26"), 29.09, 29.85, 29.2, 29.5);
	AddPoint(pKline, _T("2010-01-27"), _T("2010-01-27"), 29.02, 29.82, 29.35, 29.67);
	AddPoint(pKline, _T("2010-01-28"), _T("2010-01-28"), 28.89, 29.87, 29.84, 29.16);
	AddPoint(pKline, _T("2010-01-29"), _T("2010-01-29"), 27.66, 29.92, 29.9, 28.18);
	AddPoint(pKline, _T("2010-02-01"), _T("2010-02-01"), 27.92, 28.48, 28.39, 28.41);
	AddPoint(pKline, _T("2010-02-02"), _T("2010-02-02"), 28.14, 28.5, 28.37, 28.46);
	AddPoint(pKline, _T("2010-02-03"), _T("2010-02-03"), 28.12, 28.79, 28.26, 28.63);
	AddPoint(pKline, _T("2010-02-04"), _T("2010-02-04"), 27.81, 28.5, 28.38, 27.84);
	AddPoint(pKline, _T("2010-02-05"), _T("2010-02-05"), 27.57, 28.28, 28, 28.02);
	AddPoint(pKline, _T("2010-02-08"), _T("2010-02-08"), 27.57, 28.08, 28.01, 27.72);
	AddPoint(pKline, _T("2010-02-09"), _T("2010-02-09"), 27.75, 28.34, 27.97, 28.01);
	AddPoint(pKline, _T("2010-02-10"), _T("2010-02-10"), 27.84, 28.24, 28.03, 27.99);
	AddPoint(pKline, _T("2010-02-11"), _T("2010-02-11"), 27.7, 28.4, 27.93, 28.12);
	AddPoint(pKline, _T("2010-02-12"), _T("2010-02-12"), 27.58, 28.06, 27.81, 27.93);
	AddPoint(pKline, _T("2010-02-16"), _T("2010-02-16"), 28.02, 28.37, 28.13, 28.35);
	AddPoint(pKline, _T("2010-02-17"), _T("2010-02-17"), 28.36, 28.65, 28.53, 28.59);
	AddPoint(pKline, _T("2010-02-18"), _T("2010-02-18"), 28.51, 29.03, 28.59, 28.97);
	AddPoint(pKline, _T("2010-02-19"), _T("2010-02-19"), 28.69, 28.92, 28.79, 28.77);
	AddPoint(pKline, _T("2010-02-22"), _T("2010-02-22"), 28.65, 28.94, 28.84, 28.73);
	AddPoint(pKline, _T("2010-02-23"), _T("2010-02-23"), 28.09, 28.83, 28.68, 28.33);
	AddPoint(pKline, _T("2010-02-24"), _T("2010-02-24"), 28.38, 28.79, 28.52, 28.63);
	AddPoint(pKline, _T("2010-02-25"), _T("2010-02-25"), 28.02, 28.65, 28.27, 28.6);
	AddPoint(pKline, _T("2010-02-26"), _T("2010-02-26"), 28.51, 28.85, 28.65, 28.67);
	AddPoint(pKline, _T("2010-03-01"), _T("2010-03-01"), 28.53, 29.05, 28.77, 29.02);
	AddPoint(pKline, _T("2010-03-02"), _T("2010-03-02"), 28.24, 29.3, 29.08, 28.46);
	AddPoint(pKline, _T("2010-03-09"), _T("2010-03-09"), 28.35, 28.61, 28.51, 28.46);
	return pKline;
}

void CGraphKLine::AddPoint( AGraphKLine* pKline, char* strDate,char* strShow, double dLow,double dHeight,double dOpen,double dClose)
{
	AGraphKLine::AKLinePoint point;
	point.strDate = strDate;
	point.strShow = strShow;
	point.dLow = dLow;
	point.dHeight = dHeight;
	point.dClose = dClose;
	point.dOpen = dOpen;
	pKline->m_vecKLine.push_back(point);
}

bool CGraphKLine::GetValueRange( std::string strStrockCode, std::string strStartDate, 
								std::string strEndDate, double& dMin, double& dMax )
{
	AGraphDateBase *pkLine =GetGrapData(strStrockCode);
	bool bRet = pkLine->GetRang(strStartDate, strEndDate, dMin, dMax);
	delete pkLine;
	return bRet;
}


